<!DOCTYPE html>
<html>
    <head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>号码管理- 添加号码</title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<link rel="shortcut icon" href="../favicon.ico">
	<link href="__PUBLIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="__PUBLIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
	<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
	<link href="__PUBLIC__/css/animate.css" rel="stylesheet">
	<link href="__PUBLIC__/css/style.css?v=4.1.0" rel="stylesheet">
	<link rel="stylesheet" href="__PUBLIC__/css/liandong.css"/>
	<link href="__PUBLIC__/Widget/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
	<script src="__PUBLIC__/js/plugins/layer/laydate/laydate.js"></script>
	<style>
	    .img{ width: auto !important; max-width: 128px; max-height: 128px; }
	    .img2{ width: auto !important; max-width: 64px; max-height: 64px; }
	    .img_default{ width: auto !important; max-width: 128px; max-height: 128px; }
	    .control-label.control-label-l{ text-align: left; }
	</style>
    </head>
    <body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
	    <div class="row">
		<div class="col-sm-12">
		    <div class="ibox float-e-margins">
			<div class="ibox-title">
			    <h5>号码管理- <small><{$columnname}></small>
			    </h5>
			    <div class="ibox-tools">
				<if condition="$id gt 0">
				    <else />
				    <if condition="$operate eq '1'">
					<a href="__CONTROLLER__/numberadd/type/2" class="btn btn-primary" style="margin-bottom: 0; margin-top:-8px;">编辑号码区间</a>
					<else />
					<a href="__CONTROLLER__/numberadd" class="btn btn-primary" style="margin-bottom: 0; margin-top:-8px;">返回</a>
				    </if>
				</if>
			    </div>
			</div>
			<div class="ibox-content">
			    <if condition="$id gt 0">
				<form method="post" class="form-horizontal" onsubmit="return false">
				    <div class="form-group">
					<label class="col-sm-2 control-label">号码</label>
					<div class="col-sm-10 control-label" style="text-align: left;">
					    <{$number}>
					</div>
				    </div>
				    <div class="form-group">
					<label class="col-sm-2 control-label">所属号码区间</label>
					<div class="col-sm-10 control-label" style="text-align: left;">
					    <{$number_section}>
					</div>
				    </div>
				    <if condition="$operate eq '1'">
					<div class="form-group">
					    <label class="col-sm-2 control-label">类型</label>
					    <div class="col-sm-10 control-label" style="text-align: left;">
						<{$type_text}>
					    </div>
					</div>
					<else />
					<div class="form-group">
					    <label class="col-sm-2 control-label">类型</label>
					    <div class="col-sm-10">
						<select class="form-control" id="ddltype">
						    <volist name="typearr" id="typearr">
							<option value="<{$typearr.value}>" <{$typearr.selected}>><{$typearr.text}></option>
						    </volist>
						</select>
					    </div>
					</div>
				    </if>
				    <if condition="$operate eq '1'">
					<div class="form-group">
					    <label class="col-sm-2 control-label">状态</label>
					    <div class="col-sm-10 control-label" style="text-align: left;">
						<{$state_text}>
					    </div>
					</div>
					<else />
					<div class="form-group">
					    <label class="col-sm-2 control-label">状态</label>
					    <div class="col-sm-10">
						<select class="form-control" id="ddlstate">
						    <volist name="statearr" id="statearr">
							<if condition="$statearr.value eq '2'"><else /><option value="<{$statearr.value}>" <{$statearr.selected}>><{$statearr.text}></option></if>
						    </volist>
						</select>
					    </div>
					</div>
				    </if>
				    <if condition="$state eq '2'">
					<div class="form-group">
					    <label class="col-sm-2 control-label">所属项目</label>
					    <div class="col-sm-10 control-label" style="text-align: left;">
						<{$app_name}>
					    </div>
					</div>
					<div class="form-group">
					    <label class="col-sm-2 control-label">使用时间</label>
					    <div class="col-sm-10 control-label" style="text-align: left;">
						<{$stime}>
					    </div>
					</div>
				    </if>
				    <if condition="$state eq '2'">
					<div class="form-group">
					    <label class="col-sm-2 control-label">所属用户信息</label>
					    <div class="col-sm-10">
						<div style="padding: 15px 0; border:1px solid #cfdadd;">
						    <div class="form-group">
							<label class="col-sm-2 control-label">头像</label>
							<div class="col-sm-9 control-label control-label-l">
							    <if condition="$data.user_logo neq null && $data.user_logo neq ''"><img alt="未找到图片" class="img2" src="<{$data.user_logo}>" /></if>
							</div>
						    </div>
						    <div class="form-group">
							<label class="col-sm-2 control-label"><{$app_name2}>号</label>
							<div class="col-sm-9 control-label" style="text-align: left;">
							    <{$data.user_id}>
							</div>
						    </div>
						    <div class="form-group">
							<label class="col-sm-2 control-label">用户昵称</label>
							<div class="col-sm-9 control-label" style="text-align: left;">
							    <{$data.user_name}>
							</div>
						    </div>
						    <div class="form-group">
							<label class="col-sm-2 control-label">手机号码</label>
							<div class="col-sm-9 control-label" style="text-align: left;">
							    <{$data.user_phone}>
							</div>
						    </div>
						</div>
					    </div>
					</div>
				    </if>
				    <div class="form-group">
					<label class="col-sm-2 control-label">创建时间</label>
					<div class="col-sm-10 control-label" style="text-align: left;">
					    <{$ctime}>
					</div>
				    </div>
				    <if condition="$state eq '2'">
					<else />
					<div class="hr-line-dashed"></div>
					<div class="form-group">
					    <div class="col-sm-4 col-sm-offset-2">
						<if condition="$operate eq '1'">
						    <button class="btn btn-primary" type="button" onclick="number_edit()">编辑</button>
						    <else />
						    <button class="btn btn-primary" type="button" onclick="number_update_submit()">修改</button>&nbsp;&nbsp;&nbsp;
						    <button class="btn btn-white" type="reset">重置</button>
						</if>
					    </div>
					</div>
				    </if>
				</form>
				<else />
				<form method="post" class="form-horizontal" onsubmit="return false">
				    <if condition="$operate eq '1'">
					<div class="form-group">
					    <label class="col-sm-2 control-label">添加说明</label>
					    <div class="col-sm-10 control-label control-label-l">
						<label style="color:#7266ba;">1、成功创建选中号码区间内的号码，将自动解锁下一级号码区间。2、号码创建需要一定时间，请耐心等待。</label>
					    </div>
					</div>
					<else />
					<div class="form-group">
					    <label class="col-sm-2 control-label">清除说明</label>
					    <div class="col-sm-10 control-label control-label-l">
						<label style="color:red;">1、清除选中号码区间内的所有号码，不包含已被使用的号码。2、号码清除需要一定时间，请耐心等待。</label>
					    </div>
					</div>
				    </if>
				    <div class="form-group">
					<label class="col-sm-2 control-label">*号码区间</label>
					<div class="col-sm-10">
					    <select class="form-control" id="ddlnumbersection">
						<option value="0" selected="selected">-请选择号码区间-</option>
						<volist name="sectionarr" id="sectionarr">
						    <option value="<{$sectionarr.value}>" <{$sectionarr.disabled}>><{$sectionarr.text}></option>
						</volist>
					    </select>
					</div>
				    </div>
				    <if condition="$operate eq '1'">
					<div class="form-group">
					    <label class="col-sm-2 control-label">靓号</label>
					    <div class="col-sm-10">
						<textarea class="form-control" placeholder="请输入选中号码区间内的号码，多个号码请用空格隔开" id="txtprettynumber" style="height: 150px;"></textarea>
					    </div>
					</div>
				    </if>
				    <div class="hr-line-dashed"></div>
				    <div class="form-group">
					<div class="col-sm-4 col-sm-offset-2">
					    <if condition="$operate eq '1'">
						<button class="btn btn-primary" type="button" onclick="number_create_submit()">创建号码</button>&nbsp;&nbsp;&nbsp;
						<!--						<button class="btn btn-primary" type="button" onclick="number_section_reset()">编辑号码区间</button>-->
						<else />
						<!--						<button class="btn btn-primary" type="button" onclick="number_correct_submit()">纠正号码库</button>&nbsp;&nbsp;&nbsp;-->
						<button class="btn btn-danger" type="button" onclick="number_delete_submit()">清除号码</button>&nbsp;&nbsp;&nbsp;
						<!--						<button class="btn btn-primary" type="button" onclick="number_create()">返回</button>-->
					    </if>
					</div>
				    </div>
				</form>
			    </if>
			</div>
		    </div>
		</div>
	    </div>
	</div>
	<!--  全局js -->
	<script src="__PUBLIC__/js/jquery.min.js?v=2.1.4"></script>
	<script src="__PUBLIC__/js/bootstrap.min.js?v=3.3.6"></script>
	<!-- 自定义js -->
	<script src="__PUBLIC__/js/content.js?v=1.0.0"></script>
	<script src="__PUBLIC__/js/plugins/layer/layer.min.js"></script>
	<script src="__PUBLIC__/js/liandong.js"></script> 
	<script src="__PUBLIC__/js/ajaxfileupload.js"></script>
	<script src="__PUBLIC__/Widget/webuploader/0.1.5/webuploader.min.js"></script>
	<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
	<script>
						    var id = "<{$id}>";
						    var labname = "<{$btnname}>";
						    var numberupdatesubmit = "<{:U('numberupdatesubmit','','')}>";
						    var numbercreatesubmit = "<{:U('numbercreatesubmit','','')}>";
						    var numberdeletesubmit = "<{:U('numberdeletesubmit','','')}>";
						    var numbercorrectsubmit = "<{:U('numbercorrectsubmit','','shtml')}>";
						    var numberadd = "<{:U('numberadd','','')}>";
						    var numberlist = "<{:U('numberlist','','shtml')}>";
						    function number_update_submit() {
							$ddltype = $('#ddltype');
							$ddlstate = $('#ddlstate');
							var id = "<{$id}>";
							var type = $ddltype.val();
							var state = $ddlstate.val();
							layer.confirm('确定修改该号码信息吗？', function (index) {
							    layer.close(index);
							    //加载loading层
							    var loading = layer.load(1, {
								shade: [0.1, '#fff'] //0.1透明度的白色背景
							    });
							    $.post(numberupdatesubmit, {'id': id, 'type': type, 'state': state},
								    function (data) {
									if (data.ret == '1001') {
									    layer.close(loading);
									    layer.msg(data.code, {icon: 6, time: 1000});
									    setTimeout(function () {
										window.location.href = numberlist;
									    }, 1000);
									} else {
									    layer.close(loading);
									    layer.msg(data.code, {icon: 5, time: 1000});
									}
								    }, 'json');
							});
						    }
						    function number_edit() {
							window.location.href = numberadd + '/type/2/id/' + id;
						    }
						    function number_create_submit() {
							$ddlnumbersection = $('#ddlnumbersection');
							$txtprettynumber = $('#txtprettynumber');
							var numbersection = $ddlnumbersection.val();
							var prettynumber = $txtprettynumber.val();
							if (numbersection == "" || numbersection == "0") {
							    layer.alert('请选择号码区间！\r\n', {title: '提示框', icon: 0});
							    return false;
							}
							layer.confirm('将创建选中号码区间内的所有号码。<br />确定创建吗？', function (index) {
							    layer.close(index);
							    //加载loading层
							    var loading = layer.load(0, {shade: false});
//							    var loading = layer.load(1, {
//								shade: [0.1, '#fff'] //0.1透明度的白色背景
//							    });
							    $.post(numbercreatesubmit, {'id': numbersection, 'prettynumber': prettynumber},
								    function (data) {
									if (data.ret == '1001') {
									    layer.close(loading);
									    layer.msg(data.code, {icon: 6, time: 1000});
									    setTimeout(function () {
										window.location.href = numberlist;
									    }, 1000);
									} else {
									    layer.close(loading);
									    layer.msg(data.code, {icon: 5, time: 1000});
									}
								    }, 'json');
							});
						    }
						    function number_create() {
							window.location.href = numberadd;
						    }
						    function number_section_reset() {
							window.location.href = numberadd + '/type/2';
						    }
						    function number_delete_submit() {
							$ddlnumbersection = $('#ddlnumbersection');
							var numbersection = $ddlnumbersection.val();
							if (numbersection == "" || numbersection == "0") {
							    layer.alert('请选择号码区间！\r\n', {title: '提示框', icon: 0});
							    return false;
							}
							layer.confirm('将清除选中号码区间内的所有号码。<br />确定清除吗？', function (index) {
							    layer.close(index);
							    //加载loading层
							    var loading = layer.load(0, {shade: false});
//							    var loading = layer.load(1, {
//								shade: [0.1, '#fff'] //0.1透明度的白色背景
//							    });
							    $.post(numberdeletesubmit, {'id': numbersection},
								    function (data) {
									if (data.ret == '1001') {
									    layer.close(loading);
									    layer.msg(data.code, {icon: 6, time: 1000});
									    setTimeout(function () {
										window.location.reload();
									    }, 1000);
									} else {
									    layer.close(loading);
									    layer.msg(data.code, {icon: 5, time: 1000});
									}
								    }, 'json');
							});
						    }
						    function number_correct_submit() {
							$ddlnumbersection = $('#ddlnumbersection');
							var numbersection = $ddlnumbersection.val();
							if (numbersection == "" || numbersection == "0") {
							    layer.alert('请选择号码区间！\r\n', {title: '提示框', icon: 0});
							    return false;
							}
							layer.confirm('确定纠正号码库吗？', function (index) {
							    layer.close(index);
							    //加载loading层
							    var loading = layer.load(0, {shade: false});
//							    var loading = layer.load(1, {
//								shade: [0.1, '#fff'] //0.1透明度的白色背景
//							    });
							    $.post(numbercorrectsubmit, {'id': numbersection},
								    function (data) {
									if (data.ret == '1001') {
									    layer.close(loading);
									    layer.msg(data.code, {icon: 6, time: 1000});
									    setTimeout(function () {
										window.location.reload();
									    }, 1000);
									} else {
									    layer.close(loading);
									    layer.msg(data.code, {icon: 5, time: 1000});
									}
								    }, 'json');
							});
						    }

	</script>
    </body>
</html>
